import 'dart:async';

import 'package:event_bus/event_bus.dart';

abstract class EventBusUtil {
  static final  EventBus _eventBus = EventBus();

  /// 开启eventbus订阅
  ///
  /// 可配合 StreamSubscriptionManagerMixin 统一销毁
  static StreamSubscription<dynamic> listen(void Function(dynamic event) onData) {
    return _eventBus.on().listen(onData);
  }

  /// 发送事件
  static void emit(dynamic event) {
    _eventBus.fire(event);
  }
}
